<template>
  <view class="would_like_box">
    <scroll-view scroll-x="true" class="scroll" :scroll-with-animation="true">
      <block>
        <view @click="goDetail(item.item_id)" class="item" v-for="(item,index) in likeList" :key="index">
          <view class="item_img" @click="previewImg(item, itemDetail.imgs)">
            <ImageLoad :src="item.pict_url" mode="widthFix"/>
          </view>
          <view class="item_title">{{item.dtitle}}</view>
          <view class="tab"><text class="item_coupon">{{item.coupon_amount}}元券</text></view>
          <view class="tab"><text class="item_price">券后价￥{{toFidexFun(item.zk_final_price - item.coupon_amount)}}</text></view>
        </view>
      </block>
    </scroll-view>
  </view>
</template>

<script>
  import ImageLoad from '@/pages/pagecomponents/other/imageload'
  export default {
    components: {
      ImageLoad,
    },
    props: {
      likeList: {
        type: Array
      }
    },
    data() {
      return {}
    },
    onLoad() {},
    methods: {
      goDetail(itemId) {
        if (itemId) {
          // 广告位不存在goosdId
          uni.navigateTo({
            url: `/pages/itemdetail/index?goodsId=${itemId}`
          });
        }
      },
      toFidexFun(num){
        return num.toFixed(2)
      },
    }
  }
</script>

<style scoped lang="scss">
  .would_like_box {
    width: 100%;
    .scroll {
      width: 100%;
      white-space: nowrap;
      .item {
        width: 220upx;
        margin-right: 10upx;
        display: inline-block;
        .item_img {
          border-radius: 10upx;
          width: 200upx;
          height: 200upx;
          overflow: hidden;
        }
        .item_title {
          width: 100%;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
        }
        .tab {
          margin-top: 10upx;
          .item_coupon {
            padding: 5upx 10upx;
            display: inline-block;
            color: #f4757e;
            background-color: #feeae9;
          }
        }
        .item_price {
          margin-top: 10upx;
          font-size: 28upx;
          color: #2f5085;
        }
      }
    }
  }
</style>
